package com.mo.star.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBCutil {
    static {//加载驱动
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

    }
    private static final String url = "jdbc:mysql://47.120.52.200:3306/Library?characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true";
    private static final String useName = "root";
    private static final String pwd = "QAXuh147##";
   /**
    * 获取数据库连接
    * */
    public static Connection connection(){
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url, useName, pwd);
        } catch (SQLException e) {
           e.getMessage();
        }
        return conn;
    }
}
